module.exports = function ($scope, $resource, obj, $modalInstance, toaster) {

    $scope.obj = {
        'cost_price': obj.cost_price,
        'open_company': '0',
        'unify_float_price': 0,
        'sale_code': obj.code,
    }

    $scope.ok = function(){
        $scope.obj.unify_float_price = $scope.obj.unify_float_price || 0;
        if($scope.obj.unify_float_price < 0){
            toaster.warning({title: '', body: '统一加价不能少于0元'});
            return;
        }
        $resource('/api/ac/tc/ticketSaleAuthService/updateOpen', {}, {}).save($scope.obj, function(res){
            if (res.errcode === 0 && res.data.msg === 'success') {
                toaster.success({title: '', body: '成功'});
                $modalInstance.close($scope.obj);
            } else {
                toaster.error({title: '', body: '失败'});
            }
        });
    }

    $scope.cancel = function () {
        $scope.obj.open_company = '1';
        $modalInstance.close($scope.obj);
    }

};